﻿<%@ Page Language="C#" MasterPageFile="~/Templates/top.master" AutoEventWireup="true" CodeFile="login.aspx.cs" Inherits="login" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<div class="setmap" style="margin-left:3px;">您当前的位置： 登陆</div>
        
					   	 <div class="login-count">
                        
                            <div class="login">
                             
                             <div id="div-margin" style="width:425px; color:#404040;">
                                <div  id="divMsg" style="height:20px; margin-top:10px;">
                                        
                                    </div>
                                <table cellpadding="5" cellspacing="3" border="1" style=" width:425px; margin-left:50px;" >
                                     
                                    <tr><td colspan="3">&nbsp;</td></tr>
                                    <tr>
                                        <td style="width: 73px; height: 27px;" align="right">用户名：</td>
                                        <td align="left" style="width: 146px; height: 27px;">
                                            <asp:TextBox  onblur="checkUserName(this)" ID="txtLoginName" runat="server"></asp:TextBox>
                                        
                                            </td><td align="left" style="height: 27px"><a href="registered.aspx" target="_blank" style="color:#404040;">立即注册</a> </td>
                                    </tr> 
                                    <tr><td style="width: 73px; height: 27px;" align="right">密 码：</td>
                                        <td align="left" style="width: 146px"  >
                                            <asp:TextBox onblur="checkPwd(this)"  ID="txtPwd" TextMode="Password" runat="server" Width="126px"></asp:TextBox></td>
                                    </tr> 
                                    <tr><td align="right" style=" height: 27px;" >验证码</td>
                                        <td  align="left" style="  width: 146px; vertical-align:bottom">
                                            <asp:TextBox onblur="checkCode(this)" ID="txtCheckCode" runat="server"></asp:TextBox>
                                            
                                            </td>
                                        <td align="left" style=" "><img id="vCode" src="GetValidate.aspx" alt="" style="cursor:hand;" onclick="codeRefresh(this);return false;"/></td>
                                    </tr>
                                    <tr><td colspan="3">
                                        &nbsp;</td> </tr>
                                    <tr><td colspan="3"  style="color:#ff0000;">
                                        <asp:Button ID="Button1" OnClientClick="return checkForm();" runat="server" style="background-image:url(img/login_button.gif); height:42px; width:125px; border:0; color:#FFF; font-size:12px; font-weight:bold;" Text="登  录" OnClick="Button1_Click" />
                                        <asp:Label ID="lblAlert" runat="server"></asp:Label></td></tr>
                                </table>
                             <!--
                                <span>*用户名：<input type="text" size="16"/><span><a href="registered.aspx" target="_blank">立即注册</a></span></span>
                                <span><p>*密码：<input type="password"  size="16"/><span>忘记密码？</span></p></span>
                                <span><input type="submit" value="登  录" style="background-image:url(img/login_button.gif); height:42px; width:125px; border:0; color:#FFF; font-size:12px; font-weight:bold;"/>
                                </span> -->
                                </div>
                            </div>
                         </div>                     
    <script type="text/javascript" language="javascript">
        function codeRefresh(obj)
        {
            obj.src = "GetValidate.aspx?pcode=" + (Math.random() *1000);
        }
        function checkUserName(obj) 
        {
            clearMsg(); 
            var pass = false;
            var msg = document.getElementById("divMsg");
            var strDiv = "<div style=\"text-align:left; margin-left:60px; width:300px; background-color:#fff2f2; vertical-align:middle; color:#404040; border-right: red 1px solid; border-top: red 1px solid; border-left: red 1px solid; border-bottom: red 1px solid;\"><img src=\".\\img\\delete.gif\"/> ";
            
            if (obj.value == "") 
            {
                msg.innerHTML = strDiv + " 此项为必填项，请输入有效的用户名</div>";
            } 
            else 
            {
                if (!/^(?!\d)[a-z0-9(\_)]{4,20}$/.test(obj.value)) {
                    msg.innerHTML = strDiv +" 用户名输入有误</div>";
                } else if (!isNaN(obj.value)) {
                    msg.innerHTML = strDiv + " 用户名不能为纯数字</div>";
                }  else {
                    msg.innerHTML = "";
                    pass = true;
                }
            } 
            return pass;
        }
        function checkPwd(obj) {
            var pass = false;
            var msg = document.getElementById("divMsg");
            var strDiv = "<div style=\"text-align:left; margin-left:60px; width:300px; background-color:#fff2f2; vertical-align:middle; color:#404040; border-right: red 1px solid; border-top: red 1px solid; border-left: red 1px solid; border-bottom: red 1px solid;\"><img src=\".\\img\\delete.gif\"/>";
            
            if (obj.value == "" || obj.value.length < 6 || obj.value.length > 16) {
                msg.innerHTML =strDiv + " 密码长度必须为6-16个字符</div>";
            } else {
                pass = true;
                msg.innerHTML = "&nbsp;";
            } 
            return pass;
        }
        function checkCode(obj) {
            var msg = document.getElementById("divMsg");
            var pass = false;
            var strDiv = "<div style=\"text-align:left; margin-left:60px; width:300px; background-color:#fff2f2; vertical-align:middle; color:#404040; border-right: red 1px solid; border-top: red 1px solid; border-left: red 1px solid; border-bottom: red 1px solid;\"><img src=\".\\img\\delete.gif\"/>";
            
            if (obj.value == "") {
                msg.innerHTML =strDiv + " 请填写验证码</div>";
            } else {
                pass = true;
                msg.innerHTML = "&nbsp;"
            } 
            return pass;
        }
        function clearMsg()
        {
            var msg =  document.getElementById("divMsg");
            msg.innerTHML="";
        }
        function checkForm() {
            var form = document.forms[0];
            if (!checkUserName(form.ctl00$ContentPlaceHolder1$txtLoginName)) {
                form.ctl00$ContentPlaceHolder1$txtLoginName.focus();
                return false;
            }
           
            if (!checkPwd(form.ctl00$ContentPlaceHolder1$txtPwd)) {
                form.ctl00$ContentPlaceHolder1$txtPwd.focus();
                return false;
            } 
            if (!checkCode(form.ctl00$ContentPlaceHolder1$txtCheckCode)) {
                form.ctl00$ContentPlaceHolder1$txtCheckCode.focus();
                return false;
            }
            return true;
        }
    </script>
</asp:Content>

